using UnityEngine;


public class Skill_Base 
{
	private int ID;						//唯一标识

	private int targetType;				//目标类型
	private int targetRelation;			//目标关系
	private int targetNumber;			//目标数量上限

	private int costType;				//消耗类型
	private int cost;					//技能消耗

	private int coolDownTime;			//冷却时间，使用后计时。
	private int usableTimes;			//可用次数，使用成功减一，冷却后加一
	private int usableMaxTimes;			//最大可用次数
	
	private float distance;				//作用距离
	private float distanceHeight;		//作用高度

	private float canBreakTime;			//可打断时间
	private float breakPenalty;			//打断cd惩罚程度
	private Timer breakTimer;


	public float hitTime;				//命中时间&发射子弹时间

	private Timer coolDownTimer;				//计时用定时器

	public delegate void Skill_Base_EventHandler();
    public event Skill_Base_EventHandler Event_BeCantBreak;
	
	public Skill_Base()
	{

	}

	public Skill_Base(int id)
	{

	}
	public Skill_Base(int id,int cd,int distance,int target_type = 1,int target_relation = 1)
	{
		ID = id;
		coolDownTime = cd;
		targetType = target_type;
		targetRelation = target_relation;
		usableMaxTimes = 1;
		usableTimes = 1;
		canBreakTime = 0;
	}
#region check
	public bool CheckCoolDown()
	{
		if (usableTimes > 0) 
		{
			return true;
		}
		return false;
	}

	public bool CheckCost()
	{
		return true;
	}

	public bool CheckTarget()
	{
		return true;
	}

	public bool CheckDistance()
	{
		return true;
	}

	public bool UseCheck()
	{
		if (CheckCoolDown()&&CheckCost()&&CheckTarget()&&CheckDistance()) 
		{
			return true;
		}
		return false;
	}
#endregion

	public void CoolDown()
	{
		if (usableTimes >= 1) 
		{
			usableTimes -= 1;
		}
		else
		{
			usableTimes = 0;
		}
		coolDownTimer = new Timer(coolDownTime);
		coolDownTimer.tick += delegate()
		{
			if (usableTimes < usableMaxTimes) 
			{
				usableTimes += 1;
			}
		};
		coolDownTimer.Start();
	}
	public void BreakTimer()
	{
		if (canBreakTime > 0)
		{
			breakTimer = new Timer(canBreakTime);
			breakTimer.tick += delegate()
			{
				Event_BeCantBreak();
			};
			breakTimer.Start();
		}
		else 
		{
			Event_BeCantBreak();
		}
	}
	public bool TargetCheck()
	{
		return true;
	}
	public void Break()
	{

	}
	public void Cost()
	{

	}

}